package jxtend.processor.eclipse.visitor.replace;

import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;

@SuppressWarnings("restriction")
public class AnnotationTypeReplaceHandler implements ASTNodeReplaceHandler {

	@Override
	public boolean replaceNode(ASTNode parentNode, ASTNode originalNode, ASTNode newNode) {
		if (!(parentNode instanceof Annotation) || originalNode != ((Annotation) parentNode).type
				|| !(newNode instanceof TypeReference)) {
			return false;
		}

		((Annotation) parentNode).type = (TypeReference) newNode;

		return true;
	}

}
